home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93c.txt / 000014_icon-group-sender _Tue Jul 20 11:22:30 1993.msg < prev    next >
Internet Message Format  |  1994-02-02  |  1KB

  1. Received: by cheltenham.cs.arizona.edu; Tue, 20 Jul 1993 13:44:22 MST
  2. Message-Id: <9307201822.AA19766@hpclpax.cup.hp.com>
  3. To: Paul_Abrahams@MTS.cc.Wayne.edu
  4. Cc: icon-group@cs.arizona.edu
  5. Subject: Re: Mystery about "every" 
  6. Date: Tue, 20 Jul 93 11:22:30 -0700
  7. From: Cary Coutant <cary@hpclpax.cup.hp.com>
  8. Status: R
  9. Errors-To: icon-group-errors@cs.arizona.edu
  10.  
  11. >    every retval :=  8 * retval + ord(!s) - ord("0")
  12. >  
  13. > Now the output of the program is 3 (the last digit), not 83.
  14. >  
  15. > Can anyone explain to me what's going on?
  16.  
  17. Try reversing the operands of the "+" operation:
  18.  
  19.     every retval := ord(!s) - ord("0") + 8 * retval
  20.  
  21. Your problem was that the every was resuming the expression
  22. from the last suspended generator, so "8 * retval" was never
  23. being reevaluated.
  24.  
  25. In situations like this, it's sometimes useful to replace a
  26. built-in operator with your own procedure, so you can see
  27. what's going on by setting TRACE.  For example:
  28.  
  29.     every retval :=  add(8 * retval, ord(!s) - ord("0"))
  30.  
  31. Cary Coutant
  32. Hewlett-Packard
  33. California Language Lab
  34.